import numpy as np


x = np.random.random((10,1))
x1 = np.random.random((10,1))*0.5
y = []
for i in range(20):
    if i<10:
        y.append([0])
        continue
    y.append([1])

x = np.append(x,x1)
y = np.array(y)
print(y.shape)
data = []
for i in range(x.shape[0]):
    data.append((x[i],y[i]))
data = np.array(data)

w0 = np.random.random((2,4))
w1=np.random.random((4,1))

print(data.shape)
for i in range(600):

    l1 = 1/(1+np.exp(-np.matmul(data,w0)))
    out = 1/(1+np.exp(-np.matmul(l1,w1)))

    loss = y - out
    if(i%50==0):
        print(np.mean(np.abs( loss)))
    l1_delta = loss * (out*(1-out))
    l0_delta = l1_delta.dot(w1.T) * (l1*(1-l1))
    w1 +=  np.matmul(l1.T,l1_delta)
    w0 += np.matmul(data.T,l0_delta)




